import Vuex from 'vuex';
import Vue from 'vue';

Vue.use(Vuex);

const actions = {
    increment(miniStore, value) {
        miniStore.commit('increment', value);
    },
    decrement(miniStore, value) {
        miniStore.commit('decrement', value)
    },
    incrementIfOdd(miniStore, value) {
        miniStore.commit('incrementIfOdd', value)
    }
}

const mutations = {
    increment(state, value) {
        state.sum += value
    },
    decrement(state, value) {
        state.sum -= value
    },
    incrementIfOdd(state, value) {
        state.sum += value
    },
    incrementWait(state, value) {
        state.sum += value
    }
}

const state = {
    sum: 0
}

export default new Vuex.Store({
    actions,
    mutations,
    state
})